package cn.edu.anan.custom;

import com.alibaba.csp.sentinel.adapter.spring.webmvc.callback.RequestOriginParser;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 扩展来源解析器
 * </p>
 *
 * @author yanghouhua@edu.com.cn
 * @since 2021/8/6
 */
@Component
public class MyRequestOriginParser implements RequestOriginParser {

    /**
     * 解析来源
     * @param request
     * @return
     */
    public String parseOrigin(HttpServletRequest request) {
        // 1.这里从请求参数中获取origin（实际应用中，建议从http请求头获取更佳！）
        String origin = request.getParameter("origin");

        return origin;
    }
}
